package com.wakala.employment.fragment.other;

import android.annotation.SuppressLint;
import android.os.Bundle;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;

import android.os.Handler;
import android.os.Looper;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.JavascriptInterface;

import com.leaf.library.StatusBarUtil;
import com.wakala.employment.R;
import com.wakala.employment.core.webview.BaseWebViewFragment;
import com.wakala.employment.databinding.FragmentCompanyCertificationBinding;
import com.wakala.employment.databinding.FragmentUserIntegralBinding;
import com.wakala.employment.utils.Utils;
import com.xuexiang.xpage.annotation.Page;
import com.xuexiang.xpage.enums.CoreAnim;
import com.xuexiang.xui.utils.XToastUtils;
import com.xuexiang.xui.widget.actionbar.TitleBar;

import java.util.Objects;

/**
 * A simple {@link Fragment} subclass.
 * Use the {@link CompanyCertificationFragment#} factory method to
 * create an instance of this fragment.
 */
@Page(anim = CoreAnim.none)
public class CompanyCertificationFragment extends BaseWebViewFragment<FragmentCompanyCertificationBinding> implements View.OnClickListener {

    private Handler mHandler = new Handler(Looper.getMainLooper());


    @NonNull
    @Override
    protected FragmentCompanyCertificationBinding viewBindingInflate(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, boolean attachToRoot) {
        return FragmentCompanyCertificationBinding.inflate(inflater, container, attachToRoot);
    }

    @SuppressLint("UseCompatLoadingForDrawables")
    @Override
    protected TitleBar initTitle() {
        TitleBar titleBar = super.initTitle();
        titleBar.setTitle("公司资质");
        titleBar.setTitleColor(R.color.black);
        titleBar.setLeftTextColor(R.color.black);
        titleBar.setLeftImageDrawable(getResources().getDrawable(R.drawable.icon_arrow_back));
        titleBar.setBackgroundResource(R.color.white);//设置标题栏背景
        StatusBarUtil.setDarkMode(requireActivity());
        //设置状态栏背景颜色，如果设置为 Color.TRANSPARENT 将会隐藏状态栏
        requireActivity().getWindow().setStatusBarColor(getResources().getColor(R.color.white));
        return titleBar;
    }

    @Override
    protected void initViews() {
        String url = "https://hlbh5.miaoyankeji.com/h5/#/pages/index/company_certification";
        mAgentWeb = Utils.createAgentWeb(this, binding.container, url);
        mAgentWeb.getJsInterfaceHolder().addJavaObject("Android", new AndroidInterface());
    }

    @Override
    public void onClick(View view) {

    }

    public  class AndroidInterface {

        @JavascriptInterface
        public void callAndroid(final String msg) {
            XToastUtils.toast("这是Js调用Android的方法，内容:" + msg);
        }
        @JavascriptInterface
        public void  toRecord(){
            openNewPage(UserIntegralRecordFragment.class);
        }

    }
}